package org.phoenix.mall.admin.common.utils;

public class PhoenixResponseJSON {
    private final Integer status;
    private final String msg;
    private final Object data;

    public PhoenixResponseJSON(Builder builder) {
        this.status = builder.status;
        this.msg = builder.msg;
        this.data = builder.data;
    }

    public static PhoenixResponseJSON ok() {
        return new Builder().status(200).msg("ok").data(null).build();
    }

    public static PhoenixResponseJSON ok(Object data) {
        return new Builder().status(200).msg("ok").data(data).build();
    }

    public static PhoenixResponseJSON ok(String msg, Object data) {
        return new Builder().status(200).msg(msg).data(data).build();
    }

    public static PhoenixResponseJSON errorMsg(String msg) {
        return new Builder().status(500).msg(msg).data(null).build();
    }

    public static PhoenixResponseJSON errorMap(Object data) {
        return new Builder().status(501).msg("error").data(data).build();
    }

    public static PhoenixResponseJSON errorTokenMsg(String msg) {
        return new Builder().status(502).msg(msg).data(null).build();
    }

    public static PhoenixResponseJSON errorException(String msg) {
        return new Builder().status(555).msg(msg).data(null).build();
    }

    public static PhoenixResponseJSON errorUserQQ(String msg) {
        return new Builder().status(556).msg(msg).data(null).build();
    }

    public static class Builder {
        private Integer status;
        private String msg;
        private Object data;

        public Builder status(Integer status) {
            this.status = status;
            return this;
        }

        public Builder msg(String msg) {
            this.msg = msg;
            return this;
        }

        public Builder data(Object data) {
            this.data = data;
            return this;
        }

        public PhoenixResponseJSON build() {
            return new PhoenixResponseJSON(this);
        }
    }

    public Integer getStatus() {
        return status;
    }

    public String getMsg() {
        return msg;
    }

    public Object getData() {
        return data;
    }
}
